import Store from 'electron-store';
class CacheManager {
    private store: Store;
    constructor() {
        this.store = new Store();
    }
    setCache(key: string, value: any, time: number = 0) {
        if (time > 0) {
            const expireTime = Date.now() + time * 1000;
            this.store.set(key, { value, expireTime });
        } else {
            this.store.set(key, value);
        }
    }
    getCache(key: string) {
        const cache: any = this.store.get(key);
        if (cache && !!cache?.expireTime && cache?.expireTime < Date.now()) {
            this.store.delete(key);
            return null;
        }
        return this.store.get(key);
    }
    deleteCache(key: string) {
        this.store.delete(key);
    }
    clearCache() {
        this.store.clear();
    }
}
export const cacheManager = new CacheManager();